package com.panfeng.xcloud.boss.provider.member.service.impl;

import com.panfeng.xcloud.boss.provider.member.dao.mapper.UserOperationLogMapperExt;
import com.panfeng.xcloud.boss.provider.member.service.IUserOperaterLogService;
import com.panfeng.xcloud.dao.base.MapperSupport;
import com.panfeng.xcloud.dao.member.entity.UserOperationLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(rollbackFor = Exception.class)
@Slf4j
public class UserOperaterLogServiceImpl extends MapperSupport<Integer, UserOperationLog, UserOperationLogMapperExt> implements IUserOperaterLogService {

    /**
     * 异步记录操作日志
     *
     * @param userId
     * @param sequenceId
     * @param operationType
     * @param operationDetail
     */
    @Override
    @Async("asyncExecutor")
    public void asynInsertOperLog(String userId, String sequenceId, int operationType, String operationDetail) {
        log.info(">>> 开始异步记录 用户操作记录UserOperaterLog，userId：{}，sequenceId：{}，operationType：{}，operationDetail：{} <<<",userId,sequenceId,operationType,operationDetail);
        UserOperationLog operationLog = new UserOperationLog();
        operationLog.setUserId(userId);
        operationLog.setSequenceId(sequenceId);
        operationLog.setOperationType(operationType);
        operationLog.setOperationDetail(operationDetail);
        super.insertSelective(operationLog);
    }

    @Override
    public void asynInsertOperLog(UserOperationLog userOperationLog) {
        super.insertSelective(userOperationLog);
    }
}
